import React from 'react';
import { Row } from 'antd';
import './voted.less';
// import bgImg from '../../imgs/checkedbg.jpg';
import q1 from '../../imgs/q1.jpg';
import q2 from '../../imgs/q2.jpg';
import q3 from '../../imgs/q3.jpg';
import q4 from '../../imgs/q4.jpg';
import q5 from '../../imgs/q5.jpg';
import q6 from '../../imgs/q6.jpg';

const bgImg = 'http://img.iaquam.com/open/quiz_top-min.png';

const data = [
    {
        id: 1,
        img: q1
    },
    {
        id: 2,
        img: q2
    },
    {
        id: 3,
        img: q3
    },
    {
        id: 4,
        img: q4
    },
    {
        id: 5,
        img: q5
    },
    {
        id: 6,
        img: q6
    }
]

const Voted = (props: any) => {

    const count = props.match.params.player - 1;
    let wechatSta: Boolean = false;
    let ua: any = navigator.userAgent.toLowerCase();
    //eslint-disable-next-line
    if(ua.match(/MicroMessenger/i) == "micromessenger") {
        wechatSta = true;
    }else{
        wechatSta = false;
    }


    function savePic() {
        if(wechatSta) {
            return
        }
        let Url = data[count].img + '?mp.wexin.qq.com';
        let blob=new Blob([''], {type:'application/octet-stream'});
        let url = URL.createObjectURL(blob);
        let a = document.createElement('a');
        a.href = Url;
        a.download = Url.replace(/(.*\/)*([^.]+.*)/ig,"$2").split("?")[0];
        let e = document.createEvent('MouseEvents');
        e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
        a.dispatchEvent(e);
        URL.revokeObjectURL(url);
    }
    
    return (
        <div className='warp'>
            <div>
                <img src={bgImg} width='100%' alt=""/>
            </div>
            {/* <Row>
                <div className='voted-peo'>
                    <img src={peoImg} alt=""/>
                </div>
            </Row> */}
            {/* <Row>
                <div className='voted-height voted-heard'>这就是您心目中的冠军</div>
            </Row> */}
            <div className='voted-img'>
                <img src={data[count].img} alt=""/>
            </div>
            <Row style={{overflow: 'hidden'}}>
                <div className='voted-height voted-down' onClick={() => savePic()}>{wechatSta ? '长按上图保存照片' : '收藏到我的图库'}</div>
            </Row>
            <Row className='voted-content'>
                《穿越 The Open 公开赛》的冠军得主是由粉丝的参与度及球手以往参赛
                数据结合计算出来的。你在抖音或微信视频号上的助威行动都会被采集，并
                成为影响赛果的粉丝参与度数据。你越积极响应邀请更多的朋友来参与，你
                点选的冠军迎面越大。
            </Row>
            <Row>
                <div className='voted-height voted-title'>助威秘诀</div>
            </Row>
            <Row className='voted-content'>
                <div>1.将你收到的冠军照片在抖音或微信视频号上发布</div>
                <div>2.发布时谨记要填写话题 <span className='voted-color'>“#TheOpen公开赛”</span></div>
                <div>3.邀请至少2个朋友<span className='voted-color'>"@XXX @YYY"</span>参与竞猜游戏，然后发布</div>
            </Row>
            <Row className='voted-content voted-copyright'>
                所有内容版权为 The R&A 和 The Open 拥有，不得抄录
            </Row>
        </div>
    );
}

export default Voted